using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class frm_itemMap : EntityTypeConfiguration<frm_item>
    {
        public frm_itemMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.item)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("frm_item");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.item).HasColumnName("item");
            this.Property(t => t.Section).HasColumnName("Section");
            this.Property(t => t.Page).HasColumnName("Page");
            this.Property(t => t.order).HasColumnName("order");

            // Relationships
            this.HasOptional(t => t.frm_section)
                .WithMany(t => t.frm_item)
                .HasForeignKey(d => d.Section);

        }
    }
}
